package com.yishan;


import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 国际化字符串批量处理
 * 读每一行文本分别进行定制化处理
 *
 * @author: yishan
 * @Date: 2021/12/30 11:33
 **/
public class ReplaceStr {

    public static void main(String[] args) throws IOException {
        //要读取的文件路径
        String filePath = "D:\\yishan\\IdeaProjects\\yishan-demo\\yishan-replace-str\\src\\main\\java\\doc\\index.vue";
        File file = new File(filePath);
        if (file.isFile() && file.exists()) {
            InputStreamReader read = new InputStreamReader(new FileInputStream(file), "UTF-8");
            BufferedReader bufferedReader = new BufferedReader(read);
            //每一行的文本内容
            String lineTxt = null;
            String obj = null;
            List<String> list = new ArrayList<String>();
            while ((lineTxt = bufferedReader.readLine()) != null) {

                if (lineTxt.contains(": {")) {
                    String[] split = lineTxt.split(":");
                    obj = split[0].trim();
                    System.out.println(obj);
                }


                if (lineTxt.contains(": '")) {
                    String[] split = lineTxt.split(":");
                    String str = split[0].trim();

                    String sss = "$t('" + obj + "." + str + "')";

                    list.add(sss);
                }
                if (lineTxt.contains("}")) {
                    break;
                }

                /*if (lineTxt.contains("title-name")) {
                    String[] split = lineTxt.split("\"");
                    list.add(split[1]);
                }
                if (lineTxt.contains("label")) {
                    String[] split = lineTxt.split("\"");
                    list.add(split[1]);
                }

                if (lineTxt.contains("<span>")) {
                    list.add(lineTxt);
                }
                if (lineTxt.contains("button")) {
                    list.add(lineTxt);
                }
                if (lineTxt.contains("</template>")) {
                    break;
                }*/
            }
            read.close();
            for (String s : list) {
                System.out.println(s);
            }
        }
    }
}